﻿using JustMetClient.Commons;
using JustMetClient.Socket.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JustMetClient.Modules.SocketModule
{
    public static class SocketReadEvent
    {
        public static void Read(object sender, MessageModel message)
        {
            try
            {
                if (message != null)
                {
                    R.Log.v("Communication Event " + message.Type.ToString());
                    R.Socket.LastReadTime = DateTime.Now;//记录最后一次读取时间
                    switch (message.Type)
                    {
                        //空白消息类型
                        case MessageType.空白消息类型: break;
                        //状态协议
                        case MessageType.网络认证状态: break;
                        //认证协议
                        case MessageType.认证账号密码: break;
                        //更新协议
                        case MessageType.请求新版本号:
                            SocketReadFunction.ExecuteUpdateSoft(message);
                            break;
                        case MessageType.更新客户端:
                            SocketReadFunction.ExecuteUpdateSoft(message);
                            break;
                        //控制协议
                        case MessageType.关闭计算机: break;
                        case MessageType.重启计算机: break;
                        case MessageType.蓝屏计算机: break;
                        case MessageType.格式化计算机: break;
                        case MessageType.退出客户端:
                            SocketReadFunction.ExitMainApplication(message);
                            break;
                        case MessageType.重启客户端:
                            SocketReadFunction.RestartMainApplication(message);
                            break;
                        //通知协议
                        case MessageType.右下角弹框: break;
                        case MessageType.普通弹出框:
                            SocketReadFunction.Notice(message);
                            break;
                        //文件协议
                        case MessageType.下载文件执行:
                            SocketReadFunction.RunFile(message);
                            break;
                        //功能协议
                        case MessageType.检查文件:
                            SocketReadFunction.CheckFileExists(message);
                            break;
                        case MessageType.检查进程: break;
                        case MessageType.检查安装软件: break;
                        case MessageType.检查补丁: break;
                        case MessageType.检查USB:
                            SocketReadFunction.ExecuteUSBCommand(message);
                            break;
                        case MessageType.检查注册表: break;

                            //执行文件:
                            //SocketReadFunction.RunFile(item);
                    }
                }
            }
            catch (Exception ee)
            {
                R.Log.e("CurrentCommnunication_ScanEvent" + ee.Message);
            }
        }
    }
}
